<%--
  Created by bothin
  At 2019/12/19 21:01
  Description: 
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%--
  Created by bothin
  At 2019/12/19 10:04
  Description:
--%>
<%@ page import="com.bothin.experiment4.enums.LogistStatusEnum" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../../component/head_link_css_js.jsp"%>

    <style>
        .layui-form-item .layui-input-inline{
            width: 280px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部区域 -->
    <%@include file="../../component/nav_header.jsp"%>
    <!-- 侧边菜单 -->
    <jsp:include page="../../component/nav_side_menu.jsp">
        <jsp:param name="nav" value="4#0" />
    </jsp:include>

    <!-- 内容主体区域 -->
    <div class="layui-body" id="LAY_app_body" style="top: 50px;">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-header layuiadmin-card-header-auto">
                    <div style="padding-bottom: 10px;">
                        <div class="layui-form-item">
                            <form action="${pageContext.request.contextPath}/logist/list">
                                <div class="layui-inline">
                                    <div class="layui-input-block" style="width: 300px;">
                                        <input type="text" name="keyword" placeholder="按物流编号/发货单号/物流公司查找" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn layuiadmin-btn-admin" type="submit">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body" style="padding-bottom: 50px;">
                    <table class="layui-table">
                        <colgroup>
                            <col width="180">
                            <col><col><col><col width="120">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>物流编号</th>
                            <th>发货单号</th>
                            <th>物流公司</th>
                            <th>下单时间</th>
                            <th>物流信息</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:set var="logist_page" scope="session" value="${pageInfo.pageNum}"/>
                        <c:forEach items="${pageInfo.list}" var="item">
                            <tr>
                                <td>${item.id}</td>
                                <td>${item.formId}</td>
                                <td>${item.logistCompany}</td>
                                <td><fmt:formatDate type="both" value="${item.createTime}"/></td>
                                <td>
                                    <c:if test="${item.getLogistStatusEnum().equals(LogistStatusEnum.NOT_SEND)}">
                                        <button data-fid="${item.formId}" data-lid="${item.id}" class="layui-btn layui-btn-primary layui-btn-xs change_logist1">${LogistStatusEnum.NOT_SEND.message}</button>
                                    </c:if>
                                    <c:if test="${item.getLogistStatusEnum().equals(LogistStatusEnum.TRANSIT)}">
                                        <button data-fid="${item.formId}" data-lid="${item.id}" class="layui-btn layui-btn-warm layui-btn-xs change_logist2">${LogistStatusEnum.TRANSIT.message}</button>
                                    </c:if>
                                    <c:if test="${item.getLogistStatusEnum().equals(LogistStatusEnum.FINISH)}">
                                        <button class="layui-btn layui-btn-normal layui-btn-xs">${LogistStatusEnum.FINISH.message}</button>
                                    </c:if>
                                </td>
                            </tr>
                        </c:forEach>

                        </tbody>
                    </table>
                    <div class="layui-btn-group" style="position: absolute;right: 14px;margin-top: 10px;">
                        <a type="button" class="layui-btn layui-btn-primary layui-btn-sm ${pageInfo.hasPreviousPage!=true?"layui-btn-disabled":''}"
                           href="${pageContext.request.contextPath}/logist/list?page=${pageInfo.pageNum-1}${key}"
                        >
                            <i class="layui-icon">&#xe603;</i>
                        </a>
                        <c:forEach var="i" begin="1" end="${pageInfo.pages}">
                            <a type="button" class="layui-btn layui-btn-${pageInfo.pageNum==i?"normal":"primary"} layui-btn-sm"
                               href="${pageContext.request.contextPath}/logist/list?page=${i}${key}">${i}</a>
                        </c:forEach>
                        <a type="button" class="layui-btn layui-btn-primary layui-btn-sm ${pageInfo.hasNextPage!=true?"layui-btn-disabled":''}"
                           href="${pageContext.request.contextPath}/logist/list?page=${pageInfo.pageNum+1}${key}"
                        >
                            <i class="layui-icon">&#xe602;</i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    layui.config({
        base: '${pageContext.request.contextPath}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','sample','useradmin','layer','form'], function(){

        var $ = layui.$
            ,form = layui.form
            ,table = layui.table,layer=layui.layer;

        $('.change_logist1').on('click', function(){
            var logistId = $(this).data('lid');
            var formId = $(this).data('fid');
            console.log(logistId)
            console.log(formId)
            layer.confirm('订单已发货? 将物流信息修改为运输中状态？', {icon: 3, title:'修改物流信息',offset: '100px'}, function(index){
                //do something
                //AJAX
                $.ajax({
                    type: 'GET',
                    url: '${pageContext.request.contextPath}/logist/change/status',
                    data: {logistId:logistId,formId:formId,status:1},
                    contentType: 'text/json',
                    dataType: 'json',
                    success: function (data) {
                        layer.msg(data.msg, {
                            offset: '100px',
                            time: 2500
                        });
                        setTimeout('location.reload();', 600);
                    }
                });
                layer.close(index);
            });
        });

        $('.change_logist2').on('click', function(){
            var logistId = $(this).data('lid');
            var formId = $(this).data('fid');
            layer.confirm('订单已完成? 将物流信息修改为已签收状态？', {icon: 3, title:'修改物流信息',offset: '100px'}, function(index){
                //do something
                //AJAX
                $.ajax({
                    type: 'GET',
                    url: '${pageContext.request.contextPath}/logist/change/status',
                    data: {logistId:logistId,formId:formId,status: 2},
                    contentType: 'text/json',
                    dataType: 'json',
                    success: function (data) {
                        layer.msg(data.msg, {
                            offset: '100px',
                            time: 2500
                        });
                        setTimeout('location.reload();', 600);
                    }
                });
                layer.close(index);
            });
        });
    });
</script>




